import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.Instant;

public class Text_Instant {

    public static void main(String[] args) {
        //创建当前时间戳对象
        Instant instant1 = Instant.now();
        //对当前时间戳减1秒
        Instant instant2 = instant1.minusSeconds(1);
        //对当前时间戳加300毫秒
        Instant instant3 = instant1.plusMillis(300);
        //判断两个对象的时间戳是否相同
        System.out.println(instant2.equals(instant3));
    }
}

/*    public static void main(String[] args) {
        Instant instant = Instant.now();
        int b = instant.getNano();
        System.out.println(b);
    }
}*/
/*    public static void main(String[] args) {
        Instant instant = Instant.now();
        long a = instant.getEpochSecond();
        System.out.println(a);

    }
}*/
/*        //先找到适合的需要的时区，创建ZoneId对象
        ZoneId zoneId = ZoneId.of("America/Port_of_Spain");
        //然后根据 now() 方法传入ZoneId对象来创建ZonedDateTime
        ZonedDateTime zonedDateTime = ZonedDateTime.now(zoneId);
        //再有ZonedDateTime类中实例方法 toInstant() 得到 Instant类型的对象。
        Instant instant = zonedDateTime.toInstant();

        System.out.println(instant);


    }
}*/
/*        Instant istand = Instant.now();
        System.out.println(istand);

    }
}*/
